package com.coding365.service.user.controller;


import com.coding365.service.user.dao.LagouAuthCodeMapper;
import com.coding365.service.user.entity.LagouAuthCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {


    @Value("${spring.datasource.username}")
    private String username;

    @Autowired
    private LagouAuthCodeMapper lagouAuthCodeMapper;

    @GetMapping("test")
    public void test(){
        System.out.println("======>" + username);
    }

    @PostMapping("test/insert")
    public void test2(@RequestBody LagouAuthCode lagouAuthCode){
        lagouAuthCodeMapper.insertAuthCode(lagouAuthCode);
    }

    @GetMapping("test/list")
    public void test2(){
        List<LagouAuthCode> lagouAuthCodes = lagouAuthCodeMapper.selectAllAuthCode();
        for (LagouAuthCode lagouAuthCode: lagouAuthCodes){
            System.out.println(lagouAuthCode);
        }

    }

}
